/**
*      author: Y_Yao
*      created: 2025-02-22 13:31:54
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 10 + 6;
int n;
int a[N],A[N],B[N];
int ans;
int b[N];

void solve()
{
    cin >> n;
    for(int i = 1;i <= n;i++) cin >> a[i];
    int max_a = INF;
    for(int i = 1;i <= n;i++)
    {
        cin >> A[i];
        if(A[i] == 0) continue;
        max_a = min(max_a,a[i] / A[i]);
    }
    for(int i = 1;i <= n;i++) cin >> B[i];

    for(int i = max_a;i >= 0;i--)
    {
        //A做i个
        for(int j = 1;j <= n;j++)
        {
            b[j] = a[j] - i * A[j];
        }
        int max_b = INF;
        for(int j = 1;j <= n;j++)
        {
            if(B[j] == 0) continue;
            max_b = min(max_b,b[j] / B[j]);
        }
        ans = max(ans,i + max_b);
    }
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}